#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""  
@Project : pythonProject01
@File : subdomain_val.py
@Author : erhu
@Time : 2025/9/9 22:14  
@脚本说明 : 
"""
import threading
import warnings
import requests
warnings.filterwarnings("ignore")
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
}
def subdomain_scan(domain, sub):
    host1 = "http://" + sub + "." + domain
    host2 = "https://" + sub + "." + domain
    try:
        response1 = requests.get(host1, headers=headers, timeout=1)
        if response1.status_code in [200,301,302,401,403,404]:
            print(f"[+] {sub}.{domain} 存活")
    except:
        try:
            response2 = requests.get(host2, headers=headers, timeout=1)
            if response2.status_code in [200,301,302,401,403,404]:
                print(f"[+] {sub}.{domain} 存活")
        except:
            pass
def subdm_run(domain, subs):
    threads = []
    print("======子域名扫描======")
    for sub in subs:
        sub = sub.strip()
        t = threading.Thread(target=subdomain_scan, args=(domain, sub))
        t.start()
        threads.append(t)
    for t in threads:
        t.join()
    print("扫描结束")